import request from '@/utils/request.js'

//注册接口
// export const userRegisterService = ({ username, password, repassword }) => {
//   return request.post('/api/reg', { username, password, repassword })
// }

//登录接口
export const userLoginService = ({ username, password }) => {
  return request.get('/user/login', {
    params: { username, password }
  })
}

//获取用户基本信息
// export const userGetInfoService = () => {
//   return request.get('/my/userinfo')
// }

//更新用户基本资料
// export const userUpdateInfoService = ({ id, nickname, email }) => {
//   return request.put('/my/userinfo', { id, nickname, email })
// }
// export const userUpdateInfoService = (data) => {
//   return request.put('/my/userinfo', data)
// }

//更新用户密码
// export const userUpdatePasswordService = ({ old_pwd, new_pwd, re_pwd }) => {
//   return request.patch('/my/updatepwd', { old_pwd, new_pwd, re_pwd })
// }

// //更新用户头像
// export const userUpdateAvatarService = (avatar) => {
//   return request.patch('/my/update/avatar', { avatar })
// }

//------------------------------------------------------------------------------
export const GetUserService = () => {
  return request.get('/user/list')
}

export const AddUserService = (data) => {
  return request.post('/user/save', data)
}

export const EditUserService = (data) => {
  return request.put('/user/update', data)
}

export const DelUserService = (id) => {
  return request.delete('/user/delete', {
    params: { id }
  })
}

export const GetUserDetailService = (id) => {
  return request.get('/user/findById', {
    params: { id }
  })
}

export const GetUserFindByQueryService = (query) => {
  return request.get('/user/findByQuery', {
    params: {query}
  })
}
